using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using DocumentManagement.Models;
using System.Web.UI;
using DocumentManagement.Views;

namespace DocumentManagement.Controllers
{
    [OutputCache(Location = OutputCacheLocation.None, NoStore = true)]
    [HandleError]
    public class BaseController : Controller
    {
        public BaseController()
        {

        }

        protected YaoHuaModel Model
        {
            get
            {
                return new YaoHuaModel(AuthenticatedUser);
            }
        }
        public YuanGong AuthenticatedUser { set; get; }

        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            if (filterContext.Exception == null)
            {
                BaseViewData d = (BaseViewData)filterContext.Controller.ViewData.Model;

                if (d == null)
                {
                    d = new BaseViewData() { CurrentEmployee = AuthenticatedUser };
                    filterContext.Controller.ViewData.Model = d;
                }

                d.CurrentEmployee = AuthenticatedUser;
            }
        }
    }
}
